package com.hu.zhcc.shiro.service.Appointment;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.EntryMapper;
import com.hu.zhcc.shiro.entity.Appointment.Entry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EntryServiceImpl implements EntryService {

    @Autowired
    private EntryMapper entryMapper;

    @Override
    public Page<Entry> selectEntryAll(Map<String, String> map, String value) {
        Integer offset = Integer.valueOf(map.get("offset"));
        Integer limit = Integer.valueOf(map.get("limit"));
        PageHelper.startPage(offset, limit);
        List<Entry> entries = entryMapper.selectEntryAll(value);
        PageInfo<Entry> pageInfo = new PageInfo<>(entries);
        return new Page<Entry>(pageInfo.getTotal(), entries);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return entryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(Entry record) {
        return entryMapper.insertSelective(record);
    }

    @Override
    public Entry updateBeforeById(int id) {
        return entryMapper.updateBeforeById(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Entry record) {
        return entryMapper.updateByPrimaryKeySelective(record);
    }
}
